﻿using System;
using System.IO;

namespace woaC2.SocketLib
{
    /// <summary>
    /// Ghi Chép
    /// </summary>
    public class SocketLog
    {
        public static void Write(string str, params object[] par)
        {
            string dirPath = Directory.GetCurrentDirectory() + @"\Log\" + DateTime.Now.ToString("dd-MM-yy");

            if (!Directory.Exists(dirPath)) Directory.CreateDirectory(dirPath);

            string filePath = dirPath + @"\SocketLog.txt";

            StreamWriter fileWriter = null;

            if (File.Exists(filePath))
                fileWriter = File.AppendText(filePath);
            else
                fileWriter = File.CreateText(filePath);

            try
            {                
                fileWriter.WriteLine("[" + DateTime.Now + "]:" + str, par);
                fileWriter.WriteLine();
                fileWriter.WriteLine();
            }
            finally
            {
                fileWriter.Close();
            }
        }

    }
}
